<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Permissions extends Base
{
    use HasFactory;
    // 获取全部的数据
    public function getAllList() {
        $data = self::get()->toArray();
        return $this->subTree($data);
    }
    // 获取子id的数据
    public function getSubTreeIdArr($id)
    {
        $data = self::get()->toArray();
        return $this->subTreeId($data,$id);

    }
    //列表
    public function treeData($auth){

        $menuData = Permissions::where('is_menu',1)->whereIn('id',$auth)->get()->toArray();

        return $this->subTree($menuData);
    }

    // 获取列表
    public function getLevelList() {
        $data = self::get()->toArray();
        return $this->treeLevel($data);
    }
}
